package com.kehutong.payfees.entity.record;

import java.math.BigDecimal;

import org.coraframework.json.annotation.JSONField;
import org.coraframework.orm.Entity;
import org.coraframework.orm.annotation.Column;
import org.coraframework.orm.annotation.Table;

import com.kehutong.payfees.enums.AccountType;

/**
 * 用户账号,每个会员一个
 * 
 * @author liuzhen (liuxing521a@163.com)
 * @createTime 2017年3月21日下午3:07:11
 */
@Table(value = "t_account", multi = true)
public class Account extends Entity {

	private static final long serialVersionUID = -4693238525886228167L;
	
	protected Account(String code) {
		super(code);
	}
	
	@Column(comment="账户类型[1:业主; 2:小区; 3:物业]")
	private AccountType type;

    @Column(comment="余额(元)")
    private BigDecimal useAmt;

    @JSONField(serialize = false)
    @Column(length=32, comment="账户密码")
    private String password;

    @Column(comment="账户状态 0:正常, 1:冻结(只可入账, 不可出账) ")
    private boolean frozened;
    
	public AccountType getType() {
		return type;
	}

	public void setType(AccountType type) {
		this.type = type;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public BigDecimal getUseAmt() {
		return useAmt;
	}

	public void setUseAmt(BigDecimal useAmt) {
		this.useAmt = useAmt;
	}
	
	public void addUserAmt(BigDecimal useAmt) {
		this.useAmt = this.useAmt.add(useAmt);
	}
	
	public void decUserAmt(BigDecimal useAmt) {
		this.useAmt = this.useAmt.subtract(useAmt);
	}

	public boolean isFrozened() {
		return frozened;
	}

	public void setFrozened(boolean frozened) {
		this.frozened = frozened;
	}
}